package com.crd.homeWork;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FileMapper extends Mapper<LongWritable, Text,IntWritable, Text> {

    IntWritable i=new IntWritable();
    Text text =new Text();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //将读取文件内容进行切分
        String[] spilts = value.toString().split("\t");

        for (String spilt : spilts) {
            i.set(Integer.parseInt(spilt));
            text.set(spilt);
            context.write(i,text);
        }
    }
}
